package com.yao.mssm.system.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import javax.jms.TextMessage;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.yao.mssm.annotation.DataSource;
import com.yao.mssm.config.properties.DBType;
import com.yao.mssm.system.dao.EmpDao;
import com.yao.mssm.system.dao.SysUserDao;
import com.yao.mssm.system.entity.User;
import com.yao.mssm.system.service.ISysUserService;
import com.yao.mssm.system.service.support.BaseServiceImpl;
@Service
@DataSource(DBType.OTHER_SOURCE)
public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao,User> implements ISysUserService{
	
	@Autowired 
	EmpDao empDao;
	
	@Autowired
	private JmsTemplate jmsTemplate;
	
	@Override
	public List getList() {
		List<User> list = selectList(new EntityWrapper<User>());
		System.out.println("*********************list"+list.size());
		return list;
	}
	
	@Override
	public int insertUser(User user){
		
		jmsTemplate.send(new MessageCreator() {
			@Override
			public Message createMessage(Session session) throws JMSException {
				SimpleDateFormat f = new SimpleDateFormat("HH:mm:ss");
				TextMessage m = session.createTextMessage(f.format(new Date()));
				return m;
			}
		});
		return baseMapper.insert(user);
	}
	

}
